package com.yurui.tx;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.annotation.Transactional;

public class UserService {

    private JdbcTemplate jdbcTemplate;

    private BookService bookService;

    public void getEvent(){
        System.out.println(jdbcTemplate.queryForList("select * from test.user"));
    }

    @Transactional
    public void update(String id,String name){
        jdbcTemplate.update("update test.user set name=? where id=?",new Object[]{name,id});

        getEvent();

        bookService.updateBook(id,name);

    }

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    public void setBookService(BookService bookService) {
        this.bookService = bookService;
    }
}
